package com.cskaoyan.controller.wxcontroller;

import com.cskaoyan.bean.po.MarketSearchHistory;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.chaosbean.search.vo.IndexVO;
import com.cskaoyan.service.adminservice.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jackX
 * @datetime 2022/12/31 20:19
 * @description: TODO:
 */
@RestController
@RequestMapping("wx/search")
public class SearchWeChatController {
    @Autowired
    SearchService searchService;

    //Request URL: http://182.92.235.201:8083/wx/search/index
    @RequestMapping("index")
    public BaseRespVo index() {
        IndexVO vo = searchService.indexSearch();
        return BaseRespVo.okYa(vo);
    }

    /**
     * 添加历史搜索记录
     *
     * @param keyword
     * @return
     */
    //http://182.92.235.201:8083/wx/search/helper?keyword=99
    @RequestMapping("helper")
    public BaseRespVo helper(MarketSearchHistory keyword) {

        searchService.addSearchHistory(keyword);
        return BaseRespVo.ok();
    }

    //Request URL: http://182.92.235.201:8083/wx/search/clearhistory
    @RequestMapping("clearhistory")
    public BaseRespVo clearhistory() {
        searchService.clearHistory();
        return BaseRespVo.ok();
    }

}
